<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../css/bootstrap.css">
    <script src="../js/jquery-3.7.1.min.js"></script>
    <script src="../js/bootstrap.bundle.js"></script>
    <title>模态框</title>
</head>
<body>
    <div class="container mt-3">
        <h2>点击按钮来完成注册</h2>
        <!-- data-toggle="modal"让按钮可以打开模态框 ,也可以去掉data-toggle="modal"使用jq来控制模态框弹出-->
        <!-- data-target="#registerMadal"指定要打开的模态框div的id -->
        <button type="button" class="btn btn-primary"  id="register" data-target="#registerMadal">注册</button>
        <!-- .modal创建一个模态框，模态框的内容不会显示在页面上，点击按钮才会弹出 -->
        <div class="modal fade" id="registerMadal">
            <div class="modal-dialog">
                <!-- 模态框内容 -->
                <div class="modal-content">
                    <!-- 模态框头部 -->
                    <div class="modal-header">
                        <h4 class="modal-title">注册</h4>
                        <!-- 关闭按钮和警告一样，通过data-dismiss="modal"关闭模态框 -->
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                    </div>
                    <!-- 模态框主体 -->
                    <div class="modal-body">
                        注册表单
                    </div>
                    <!-- 模态框脚 -->
                    <div class="modal-footer">
                        <button type="button" class="btn btn-danger" data-dismiss="modal">提交</button>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <script>
        $(document).ready(function(){
            // 使用jq来控制模态框弹出
            $("#register").click(function(){
                $("#registerMadal").modal();
            })
        })
    </script>

</body>
</html>